<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('编辑')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-user-resetPwd">
			<input id="id" name="id"  type="hidden"  th:value="*{id}" />
			<input id="modifyDirection" name="modifyDirection"  type="hidden"  th:value="*{modifyDirection}" />
			<input id="modifyValue" name="modifyValue"  type="hidden"  th:value="*{modifyValue}" />
			<div class="form-group">
				<label class="col-sm-3 control-label">原有内容：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" readonly="true" name="modifyContent" th:value="*{modifyContent}" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">修改内容：</label>
				<div class="col-sm-8" th:switch="*{modifyDirection}">
				     <input th:case="1" class="form-control" id="modifyValueBig" name="afterModify" type="number"  onkeyup="value=value.replace(/^0(0+)|[^\d]+/g,'')" onchange="value=value.replace(/^0(0+)|[^\d]+/g,'')"  placeholder="只需往偏大方向填写数字即可">
					 <input th:case="2" class="form-control" id="modifyValueSmall" name="afterModify" type="number"  onkeyup="value=value.replace(/^0(0+)|[^\d]+/g,'')" onchange="value=value.replace(/^0(0+)|[^\d]+/g,'')"  placeholder="只需往偏小方向填写数字即可">
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var editPrefix = ctx + "education/schedule";
		function submitHandler() {
			var modifyDirection = $('#modifyDirection').val();
			var modifyValue = $('#modifyValue').val();
			var modifyValueInt = parseInt(modifyValue)
			var modifyValueBig = $('#modifyValueBig').val();
			var modifyValueSmall = $('#modifyValueSmall').val();
			if(modifyDirection == "1"){
				if(!modifyValueBig){
					$.modal.alertWarning("修改内容必填");
					return;
				}
                var modifyValueBigInt = parseInt(modifyValueBig);
				// if(modifyValueBigInt < modifyValueInt){
				// 	$.modal.alertWarning("只能往偏大方向填写数字");
				// 	return;
				// }
			}
			if(modifyDirection == "2"){
				if(!modifyValueSmall){
					$.modal.alertWarning("修改内容必填");
					return;
				}
                var modifyValueSmallInt = parseInt(modifyValueSmall);
				// if(modifyValueSmall > modifyValue){
				// 	$.modal.alertWarning("只能往偏小方向填写数字");
				// 	return;
				// }
			}

			var data = $('#form-user-resetPwd').serialize();
			$.ajax({
				cache: true,
				type: "POST",
				url: editPrefix + "/editProgram",
				data: data,
				error: function (request) {
					$.modal.alertError("系统错误");
				},
				success: function (data) {
                    if (data.code == 0) {
                        $.modal.close();
                        parent.submitSelect();
                    } else {
                        $.modal.alertError(data.msg);
                    }
				}
			});

	    }
	</script>
</body>

</html>
